package ui;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class InterfaceSprite {
	private static String imageFilePath = "resources/ui/";
	
	private static BufferedImage EXIT_BUTTON;
	private static BufferedImage EXIT_BUTTON_HIGHLIGHT;
	private static BufferedImage START_BUTTON;
	private static BufferedImage START_BUTTON_HIGHLIGHT;
	private static BufferedImage MENU_BACKGROUND;
	private static BufferedImage TITLE;
	
	private static BufferedImage LEVEL_TAG;
	
	private static BufferedImage NUMBER_0;
	private static BufferedImage NUMBER_1;
	private static BufferedImage NUMBER_2;
	private static BufferedImage NUMBER_3;
	private static BufferedImage NUMBER_4;
	private static BufferedImage NUMBER_5;
	private static BufferedImage NUMBER_6;
	private static BufferedImage NUMBER_7;
	private static BufferedImage NUMBER_8;
	private static BufferedImage NUMBER_9;	
	
	static{
		try {
			
			EXIT_BUTTON = ImageIO.read(new File(imageFilePath+"menu/exit_button.png"));
			EXIT_BUTTON_HIGHLIGHT = ImageIO.read(new File(imageFilePath+"menu/exit_button_highlight.png"));
			START_BUTTON = ImageIO.read(new File(imageFilePath+"menu/start_button.png"));
			START_BUTTON_HIGHLIGHT = ImageIO.read(new File(imageFilePath+"menu/start_button_highlight.png"));
			MENU_BACKGROUND = ImageIO.read(new File(imageFilePath+"menu/menu_bg.png"));
			TITLE = ImageIO.read(new File(imageFilePath+"menu/title.png"));
			
			LEVEL_TAG = ImageIO.read(new File(imageFilePath+"splash/level_tag.png"));
			
			NUMBER_0 = ImageIO.read(new File(imageFilePath+"splash/number0.png"));
			NUMBER_1 = ImageIO.read(new File(imageFilePath+"splash/number1.png"));
			NUMBER_2 = ImageIO.read(new File(imageFilePath+"splash/number2.png"));
			NUMBER_3 = ImageIO.read(new File(imageFilePath+"splash/number3.png"));
			NUMBER_4 = ImageIO.read(new File(imageFilePath+"splash/number4.png"));
			NUMBER_5 = ImageIO.read(new File(imageFilePath+"splash/number5.png"));
			NUMBER_6 = ImageIO.read(new File(imageFilePath+"splash/number6.png"));
			NUMBER_7 = ImageIO.read(new File(imageFilePath+"splash/number7.png"));
			NUMBER_8 = ImageIO.read(new File(imageFilePath+"splash/number8.png"));
			NUMBER_9 = ImageIO.read(new File(imageFilePath+"splash/number9.png"));


			
		}
		catch (IOException e) {
			throw new IllegalArgumentException(e + " -> Error loading images.");
		}
	}
	
	/**
	 * Returns the image corresponding to the {@link InterfaceElement} requested.
	 * @param requestedElement {@link InterfaceElement}
	 * @return {@link BufferedImage}
	 */
	public static BufferedImage getImage(InterfaceElement requestedElement){
		switch (requestedElement) {
		case EXIT_BUTTON:			
			return EXIT_BUTTON;
		case EXIT_BUTTON_HIGHLIGHT:			
			return EXIT_BUTTON_HIGHLIGHT;
		case START_BUTTON:			
			return START_BUTTON;
		case START_BUTTON_HIGHLIGHT:			
			return START_BUTTON_HIGHLIGHT;
		case MENU_BACKGROUND:			
			return MENU_BACKGROUND;
		case TITLE:			
			return TITLE;
		case LEVEL_TAG:
			return LEVEL_TAG;			
			
		default:
			return null;
		}
	}
	
	public static BufferedImage getNumber(int num){
		switch (num) {
		case 0:
			return NUMBER_0;
		case 1:
			return NUMBER_1;
		case 2:
			return NUMBER_2;
		case 3:
			return NUMBER_3;
		case 4:
			return NUMBER_4;
		case 5:
			return NUMBER_5;
		case 6:
			return NUMBER_6;
		case 7:
			return NUMBER_7;
		case 8:
			return NUMBER_8;
		case 9:
			return NUMBER_9;
		default:
			return null;
		}
	}
}
